<?php 
/* OpenBIBLIO -- A library administration web interface
 * Copyright (C) 2002-2005 Fr&eacute;d&eacute;ric Descamps <lefred@tiscali.be>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
include_once("includes/db.inc");
include_once("includes/functions.inc");

session_start();
include_once("includes/session.inc");

ControleAcces("classelist.php",$login,$pwd,$user_id,session_id());

if(!$user_id)
{
 exit;
}

$result = biblio_db_query("SELECT login FROM admin WHERE id = $user_id" ,$db);
$myrow = biblio_db_fetch_array($result);
$user = $myrow['login'] ;

$title = _("Listing des &eacute;l&egrave;ves par classe");
include ("includes/header.inc");

$id=$_GET['id'];

if(!$id)
{
        $requete = "select * from classes order by classe";
        if(!($resultat = biblio_db_query($requete)))
        { print _("PROBLEME : ") .biblio_db_error(); }
        else 
        {
                echo "<CENTER><H3>";
		echo _("Modifier une classe");
		echo "</H3>";
                echo "<TABLE><TR><th>Classe</th><th>Action</th></tr>";
        
                while ($row = biblio_db_fetch_array($resultat)) 
	        {      
                        $classe_id = $row['id'];           
                        $classe_nom =  $row['classe'];                                
                        echo "<TR><TD>$classe_nom</TD><TD align=right><A href=\"classeslist.php?classe_nom=$classe_nom&id=$classe_id\"><IMG SRC=\"images/wh_r_arr.gif\" ALT=\"";
			echo _("choisir");
			echo "\" border=0></A></TD>";            
                }
                echo "</TABLE></CENTER>";
        }
}
else
{
    print "<CENTER><H2>Classe de $classe_nom :</H2>";
    $requete = "SELECT DISTINCT t1.nom, t1.prenom, t1.code, t2.classe FROM eleves as t1 inner join classes as t2 on t2.id = t1.classe_id where classe_id = $id and t1.del=0 order by nom, prenom "; 
    if(!($resultat = biblio_db_query($requete)))
    { print _("PROBLEME : ") .biblio_db_error(); }
    else 
    {
	put_log(6,_("listing de la classe")." : $classe_nom",$user); 
	echo "<TABLE border=1><tr><th>";
	echo _("Nom");
	echo "</th><th>";
	echo _("Pr&eacute;nom");
	echo "</th><th>";
	echo _("Code");
	echo "</th></tr>";
	$i=0;
	while ($row = biblio_db_fetch_array($resultat)) 
	{      
	        $code = $row['code'];           
		$nom =  $row['nom'];                                
		$prenom =  $row['prenom'];			        				                                
                echo "<TR><TD>$nom</TD><TD>$prenom</TD><TD>";
                echo "<img src='barcode/image.php?code=$code&style=196&type=C128A&width=250&height=50&xres=2&font=5' ALT=\"$code\"></TD></tr>"; 
        }
     }   
echo "</TABLE></CENTER>";
}
?>
<br><br>
<div>
<span id=left-text>
<A HREF="admin.php?menu=1">
<?php echo _("retour menu administration"); ?>
</A><BR>
<A HREF="index.php">
<?php echo _("retour menu principal"); ?>
</A></span>
</div>
<br>
<?php
include("includes/footer.inc");
?>
